/* ======================================= */
/* parser pour bopprocess SSA : file .bpp  */
/* ======================================= */

%{
  open Bopprocesstools

%}

%token EOF
%token INPUT
%token OUTPUT
%token EGAL 
%token <int> INT
%token <string> IDENT
%token VIRG
%token NL

%type <(string, string) Bopprocesstools.operation array> net_list
%start net_list

%%

net_list: 
  | input ope_list output  { Array.of_list ($1::$2@[$3]) }
;

break :
  | NL        { () }
  | NL break  { () }
;

input:
  | INPUT ident_list break { Input (Array.of_list $2) }
;

output:
  | OUTPUT ident_list { Output (Array.of_list $2) }
;

ope_list:
  |                  { [] }
  | op break ope_list { $1::$3 }
;

operande:
  | IDENT  { $1 }
  | INT    { string_of_int $1 }
;

op:
  | IDENT EGAL operande operande            { UnaryOperator  ($3, [|$1; $4|])  }
  | IDENT EGAL operande IDENT operande   { BinaryOperator ($4, [|$1; $3; $5|]) }
;


ident_list :
  | IDENT     { [$1] }
  | IDENT VIRG ident_list { $1::$3 }
;

